/*
 * ogre_scene_node.cpp
 *
 *  Created on: 31.03.2011
 *      Author: inkooboo
 */

#include "ogre_scene_node.hpp"

#include <OgreSceneNode.h>

ogre_scene_node_t::ogre_scene_node_t(Ogre::SceneNode *ogre_node, scalar_t y_correction) :
    scene_node_(ogre_node), y_correction_(y_correction)
{
}

ogre_scene_node_t::~ogre_scene_node_t()
{
}


void ogre_scene_node_t::update_world_transform(const world_transform_t &pos)
{
    if (!scene_node_)
    {
        return;
    }

    Ogre::Quaternion quat(pos.rotation.w, pos.rotation.x, pos.rotation.y, pos.rotation.z);

    scene_node_->setOrientation(quat);

    Ogre::Vector3 vect(pos.position.x, pos.position.y, pos.position.z);

    vect -= quat.yAxis().normalisedCopy() * y_correction_;

    scene_node_->setPosition(vect);
}
